﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MapEditor
{
    public class Vector2I : IEquatable<Vector2I>
    {
        public int x;
        public int y;

        public Vector2I()
        {
            this.x = 0;
            this.y = 0;
        }

        public Vector2I(int x, int y)
        {
            this.x = x;
            this.y = y;
        }

        public Vector2I(Vector2I other)
        {
            this.x = other.x;
            this.y = other.y;
        }

        public Vector2I set(int x, int y)
        {
            this.x = x;
            this.y = y;
            return this;
        }

        public Vector2I set(Vector2I other)
        {
            this.x = other.x;
            this.y = other.y;
            return this;
        }

        static public Vector2I operator +(Vector2I a, Vector2I b)
        {
            return new Vector2I(a.x + b.x, a.y + b.y);
        }

        static public Vector2I operator -(Vector2I a, Vector2I b)
        {
            return new Vector2I(a.x - b.x, a.y - b.y);
        }

        static public Vector2I operator +(Vector2I a, int b)
        {
            return new Vector2I(a.x + b, a.y + b);
        }

        static public Vector2I operator -(Vector2I a, int b)
        {
            return new Vector2I(a.x - b, a.y - b);
        }

        public override bool Equals(object other)
        {
            if (other == null)
                return false;
            Vector2I otherVector = other as Vector2I;
            if (otherVector == null)
                return false;

            return this.x == otherVector.x && this.y == otherVector.y;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public bool Equals(Vector2I other)
        {
            if (other == null)
                return false;
            return this.x == other.x && this.y == other.y;
        }

        public static bool operator ==(Vector2I a, Vector2I b)
        {
            if (System.Object.ReferenceEquals(a, b))
                return true;
            if (((object)a == null) || ((object)b == null))
                return false;
            return a.x == b.x && a.y == b.y;
        }

        public static bool operator !=(Vector2I a, Vector2I b)
        {
            return !(a == b);
        }
    }
}
